/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package yuhuibear.poat.test.annotation;

import java.lang.annotation.Annotation;
import java.lang.reflect.Field;

import yuhuibear.poat.annotations.relation.Table;
import yuhuibear.poat.test.entity.User;

/**
 *
 * @author yuhuibear
 */
public class AnnotationDemo {

    public static void main(String[] args) {
        annotations(User.class);
    }

    private static void annotations(Class type) {

        Annotation ans = type.getAnnotation(Table.class);
        Annotation[] anns = type.getAnnotations();
        int i =0;
        for (Annotation an : anns) {
            System.out.println("i = " + i + ", "+ an);
//            Table dbe = (Table) ans;
//            System.out.println("name : " + dbe.name());
        }
        Field[] fields = type.getDeclaredFields();
        for(Field f : fields) {
            int cnt=0;
            anns = f.getAnnotations();
            for(Annotation an : anns ){
                System.out.println("["+ cnt + "]: "+an);
                cnt ++;
            }
        }
    }
}
